<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ page session="false" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page pageEncoding="UTF-8" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Manop Service</title>
<script>
      function formSubmit()
      {
      	document.getElementById("frm1").submit();
      }
   </script>
</head>
<body>
 
<h1>Edit Car Part</h1>

	<c:url var="carPartsUrl" value="/carParts.html" />
	<a href="${carPartsUrl}">-----Back------</a>
 
 
 
<c:url var="save" value="/carParts/update.html?id=${carPart.id}" />
<form:form id="frm1" modelAttribute="carPart" method="POST" action="${save}">
 <table>
  <tr>
   <td><form:label path="name">Name:</form:label></td>
   <td><form:input path="name"/></td>
  </tr>
 
  <tr>
   <td><form:label path="detail">Detail:</form:label></td>
   <td><form:input path="detail"/></td>
  </tr>
  
  <tr>
   <td><form:label path="costPrice">Cost Price:</form:label></td>
   <td><form:input path="costPrice"/></td>
  </tr>
  
  <tr>
   <td><form:label path="salePrice">Sale Price:</form:label></td>
   <td><form:input path="salePrice"/></td>
  </tr>
  
  <tr>
   <td><form:label path="dateEnd">Date End:</form:label></td>
   <td><form:input path="dateEnd"/></td>
  </tr>
  
  <tr>
   <td><form:label path="status">Status:</form:label></td>
   <td><form:input path="status"/></td>
  </tr>
  
  <tr>
   <td><form:label path="picPath">Pic Path:</form:label></td>
   <td><form:input path="picPath"/></td>
  </tr>
   
 </table>
 
 Select Car Brand:
<select name="carBrandId" >
	<c:forEach items="${carBrands}" var="carBrand">		
		
		<c:choose>
			<c:when test="${carBrand.nameEng==brandId.nameEng}" >
				<option selected="selected" value="${carBrand.id}">${carBrand.nameEng}</option>
			</c:when>			
			<c:otherwise>
				<option value="${carBrand.id}">${carBrand.nameEng}</option>
			</c:otherwise>			
		</c:choose>
				
  	</c:forEach>
</select>
<br/> 

Select Car Model:
<select name="carModelId" >
	<c:forEach items="${carModels}" var="carModel">		
		
		<c:choose>
			<c:when test="${carModel.nameEng==modelId.nameEng}" >
				<option selected="selected" value="${carModel.id}">${carModel.nameEng}</option>
			</c:when>			
			<c:otherwise>
				<option value="${carModel.id}">${carModel.nameEng}</option>
			</c:otherwise>			
		</c:choose>
				
  	</c:forEach>
</select>
<br/> 

Select Car Type:
<select name="carTypeId" >
	<c:forEach items="${carTypes}" var="carType">		
		
		<c:choose>
			<c:when test="${carType.nameEng==typeId.nameEng}" >
				<option selected="selected" value="${carType.id}">${carType.nameEng}</option>
			</c:when>			
			<c:otherwise>
				<option value="${carType.id}">${carType.nameEng}</option>
			</c:otherwise>			
		</c:choose>
				
  	</c:forEach>
</select>
<br/> 
  <form:form modelAttribute="uploadFiles">
         <fieldset>
            <legend>Upload Picture</legend>
            <p>
               <form:label for="fileData" path="fileData">File</form:label>
               <br />
               <form:input path="fileData" type="file" />
            </p>
         </fieldset>
      </form:form>
 <input type="button" onclick="formSubmit()" value="OK" /> 
</form:form>
 
</body>
</html>